<template>
  <base-edge
    :id="id"
    :style="style"
    :path="path[0]"
    :marker-end="markerEnd"
  />

  <edge-label-renderer>
    <div
      :style="{
        pointerEvents: 'all',
        position: 'absolute',
        transform: `translate(-50%, -50%) translate(${path[1]}px,${path[2]}px)`,
      }"
    >
      <button
        class="edge-button"
        @click="removeEdges(id)"
      >
        ×
      </button>
    </div>
  </edge-label-renderer>
</template>
<script lang="ts" setup>
import { defineProps, computed } from 'vue';
import { BaseEdge, EdgeLabelRenderer, getBezierPath, useVueFlow } from '@vue-flow/core';
import type { EdgeProps } from '@vue-flow/core';

const props = defineProps<EdgeProps>();

const { removeEdges } = useVueFlow();

const path = computed(() => getBezierPath(props));
</script>

<script lang="ts">
export default {
  inheritAttrs: false
};
</script>

<style lang="less" scoped>
.edge-button {
  cursor: pointer;
  background-color: #dc3838;
  border: 0;
}

.edge-button:hover {
  box-shadow: 0 0 0 1px pink, 0 0 0 2px #f05f75;
}
</style>
